Skip to content

Conversation

ShaharNaveh
Copy link
Contributor

>>> idx1.equals(pd.Index([1, 2, 3]))
True
The dtype is been compared as well
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is been -> is

>>> idx1.equals(idx2)
False
The oreder is also been compared
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oreder is also been compared -> order is also compared

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at it, can you also add a "Parameters" section?

def equals(self, other: Any) -> bool:
"""
Determine if two Index objects contain the same elements.
Determine if two Index objects contain the same elements with the same order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could also simplify "... contain the same elements with the same order" to "... are equal" ?

We can in a second paragraph detail on what is considered as equal

>>> idx1.equals(pd.Index([1, 2, 3]))
True
The dtype is been compared as well
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dtype is actually not compared:

In [9]: pd.Int64Index([1, 2, 3]).equals(pd.UInt64Index([1, 2, 3]))                                                                                                                            
Out[9]: True

(in your example here, the values are not equal as a string is not equal to an integer)

@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Apr 5, 2020
Co-Authored-By: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche merged commit 01f7310 into pandas-dev:master Apr 6, 2020
@jorisvandenbossche
Copy link
Member

Thanks!

@ShaharNaveh ShaharNaveh deleted the DOC-Imporve-IndexEquals branch April 6, 2020 08:29
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Mention Index.equals takes into account order of arguments

4 participants